﻿using System;
using UnityEditor;
using UnityEngine;

namespace SCore.Editor.BuildPackage.Platform
{
    [Serializable]
    public abstract class BuildPlatformBase
    {
        public virtual void SBuild()
        {
            var sBuildChannel = BuildPipelineConfig.Instance._buildChannel;
            //通用设置
            PlayerSettings.productName = sBuildChannel._productName; //产品名
            PlayerSettings.companyName = sBuildChannel._companyName;
            //默认设置 
            var buildGroup = sBuildChannel.GetBuildTargetGroup();
            PlayerSettings.SetApplicationIdentifier(buildGroup, sBuildChannel._packageName); //包名
            PlayerSettings.SetManagedStrippingLevel(buildGroup, ManagedStrippingLevel.Disabled); //禁用托管代码剥离
            PlayerSettings.SetApiCompatibilityLevel(buildGroup, ApiCompatibilityLevel.NET_4_6); //.Net 使用的API版本
            PlayerSettings.SetScriptingBackend(buildGroup, ScriptingImplementation.IL2CPP);
            PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation; //自动旋转
            PlayerSettings.allowedAutorotateToLandscapeLeft = true; //自动旋转
            PlayerSettings.allowedAutorotateToLandscapeRight = true; //自动旋转
            PlayerSettings.allowedAutorotateToPortrait = false; //自动旋转
            PlayerSettings.allowedAutorotateToPortraitUpsideDown = false; //自动旋转
            PlayerSettings.stripEngineCode = false; //代码剔除关闭
            PlayerSettings.virtualRealitySupported = false; //是否支持虚拟现实
            PlayerSettings.allowUnsafeCode = true; //是否支持不安全的代码
            PlayerSettings.insecureHttpOption = InsecureHttpOption.AlwaysAllowed; // 永远支持http
            PlayerSettings.colorSpace = ColorSpace.Linear; //颜色空间
            PlayerSettings.gpuSkinning = true; //是否开启gpu蒙皮
            PlayerSettings.SetUseDefaultGraphicsAPIs(sBuildChannel.GetBuildTarget(), false); //是否使用默认的图形 API 的方法

            PlayerSettings.MTRendering = true; //
            PlayerSettings.SetMobileMTRendering(buildGroup, true); //是否开启多线程渲染
            PlayerSettings.runInBackground = true; //丢失焦点是否继续运行 
            PlayerSettings.bundleVersion = BuildPipelineConfig.Instance._version; //builde版本
            PlayerSettings.SetArchitecture(sBuildChannel.GetBuildTargetGroup(), 1); //目标处理器架构
        }
    }
}